<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>QUnit for 'asn1x509' multi-valued RDN</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script language="JavaScript" type="text/javascript" src="../jsrsasign-all-min.js"></script>
<script language="JavaScript" type="text/javascript" src="../src/base64x-1.1.js"></script>
<script language="JavaScript" type="text/javascript" src="../src/asn1x509-1.0.js"></script>
<script language="JavaScript" type="text/javascript" src="../src/asn1-1.0.js"></script>

<script type="text/javascript">
<!--
$(document).ready(function(){

test("KJUR.asn1.x509.RDN.parseString", function() {
//equal(["a", "b", "c"], ["a", "b", "c"], "a b c");
//equal(["a", "1", "c"], ["a", "b", "c"], "a b=!1 c");

deepEqual(KJUR.asn1.x509.RDN.parseString("O=a1"), ["O=a1"], "O=a1");
deepEqual(KJUR.asn1.x509.RDN.parseString("O=a1+O=a2"), ["O=a1", "O=a2"], "O=a1+O=a2");
deepEqual(KJUR.asn1.x509.RDN.parseString("O=a+O=bbbb+O=c"), ["O=a", "O=bbbb", "O=c"], "O=a+O=bbbb+O=c");
// quote plus
deepEqual(KJUR.asn1.x509.RDN.parseString("O=a+O=bb\\+bb+O=c"), ["O=a", "O=bb+bb", "O=c"], "O=a+O=bb\\+bb+O=c");
deepEqual(KJUR.asn1.x509.RDN.parseString("O=a+O=b\\+b\\+b+O=c"), ["O=a", "O=b+b+b", "O=c"], "O=a+O=b\\+b\\+b+O=c");
// quote quotation mark
deepEqual(KJUR.asn1.x509.RDN.parseString("O=a+O=\"bb+bb\"+O=c"), ["O=a", "O=bb+bb", "O=c"], "O=a+O=\"bb+bb\"+O=c");
deepEqual(KJUR.asn1.x509.RDN.parseString("O=a+O=\"b+b+b\"+O=c"), ["O=a", "O=b+b+b", "O=c"], "O=a+O=\"b+b+b\"+O=c");
});

test("KJUR.asn1.x509.RDN constructor multi-valued RDNs", function() {
equal((new KJUR.asn1.x509.RDN({str: "O=a"})).getEncodedHex(), "310a3008060355040a0c0161", "O=a");
equal((new KJUR.asn1.x509.RDN({str: "O=a+O=b"})).getEncodedHex(), "31143008060355040a0c01613008060355040a0c0162", "O=a+O=b");
equal((new KJUR.asn1.x509.RDN({str: "O=a+O=b+O=c"})).getEncodedHex(), "311e3008060355040a0c01613008060355040a0c01623008060355040a0c0163", "O=a+O=b+O=c > a b c");
equal((new KJUR.asn1.x509.RDN({str: "O=a+O=bb+O=c"})).getEncodedHex(), "311f3008060355040a0c01613008060355040a0c01633009060355040a0c026262", "O=a+O=bb+O=c > a c bb");
equal((new KJUR.asn1.x509.RDN({str: "O=a+O=b\\+b+O=c"})).getEncodedHex(), "31203008060355040a0c01613008060355040a0c0163300a060355040a0c03622b62", "O=a+O=b\\+b+O=c > a c b+b");
equal((new KJUR.asn1.x509.RDN({str: "O=a+O=\"b+b\"+O=c"})).getEncodedHex(), "31203008060355040a0c01613008060355040a0c0163300a060355040a0c03622b62", "O=a+O=\"b+b\"+O=c > a c b+b");
});

test("KJUR.asn1.x509.X500Name constructor multi-valued RDNs", function() {
equal((new KJUR.asn1.x509.X500Name({str: "/C=US/O=a/OU=b1+OU=b2"})).getEncodedHex(), "3031310b3009060355040613025553310a3008060355040a0c016131163009060355040b0c0262313009060355040b0c026232", "/C=US/O=a/OU=b1+OU=b2");
equal((new KJUR.asn1.x509.X500Name({str: "/C=US/O=a/OU=b1+CN=b2"})).getEncodedHex(), "3031310b3009060355040613025553310a3008060355040a0c01613116300906035504030c0262323009060355040b0c026231", "/C=US/O=a/OU=b1+CN=b2 SET OF ordering will be b2 b1");
});

test("KJUR.asn1.x509.X500Name.onelineToLDAP", function() {
var f = 
equal(KJUR.asn1.x509.X500Name.onelineToLDAP("/C=US/O=test"), "O=test,C=US", "/C=US/O=test");
equal(KJUR.asn1.x509.X500Name.onelineToLDAP("/C=US/O=a,b"), "O=a\\,b,C=US", "/C=US/O=a,b");
});

// openssl req -new -key a.prv -x509 -subj /C=JP/O=a\\/a -set_serial 1 -days 3652 -out aaa.cer -outform DER
// openssl req -new -key a.prv -x509 -subj /C=JP/O=b/b -set_serial 1 -days 3652 -out aaa.cer -outform DER

test("KJUR.asn1.x509.X500Name.ldapToOneline", function() {
var f = 
equal(KJUR.asn1.x509.X500Name.ldapToOneline("O=test,C=US"), "/C=US/O=test", "O=test,C=US");
equal(KJUR.asn1.x509.X500Name.ldapToOneline("O=a\\,b,C=US"), "/C=US/O=a,b", "O=a\\,b,C=US");
equal(KJUR.asn1.x509.X500Name.ldapToOneline("O=a/b,C=US"), "/C=US/O=a\\/b", "O=a/b,C=US");
});

});
-->
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<a href="index.html">TEST INDEX</a> |
<a href="qunit-do-x509-hex2dn.html">x509-hex2dn</a> |
<a href="qunit-do-asn1x509.html">asn1x509</a> |
<a href="qunit-do-asn1x509-multirdn.html">asn1x509-multirdn</a> |

</body>
</html>

